package net.hn.hnms.biz.video.job;

import lombok.extern.slf4j.Slf4j;
import net.hn.hnms.biz.video.service.IHikVisionService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;

/**
 * @Author mkq
 * @Date 2022-08-04 16:43
 * @Description
 */
@Component
@Slf4j
public class HikVersionJob {


    @Resource
    IHikVisionService hikVisionService;


    @PostConstruct
    public void init() {
        hikVisionService.regions(true);
        hikVisionService.resources(true);
        hikVisionService.onlineInfo(true);
    }

    /**
     * 定时获取在线状态
     */
    @Scheduled(fixedRateString = "${video.hikversion.onlineFixedRate:10000}")
    public void syncOnline() {
        hikVisionService.onlineInfo(true);
    }


    /**
     * 定时更新摄像头信息
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void syncResource() {
        hikVisionService.resources(true);
    }

    /**
     * 定时更新摄像头信息(带区域信息)
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void syncAllResource() {
        hikVisionService.syncAllResource(true);
    }


    /**
     * 定时更新摄像头信息
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void syncRegions() {
        hikVisionService.regions(true);
    }

}
